<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>攻防世界RE | 惜缘怀古的博客</title><meta name="keywords" content="惜缘怀古，博客"><meta name="author" content="惜缘怀古"><meta name="copyright" content="惜缘怀古"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Reversing-x64Elf-100追踪main 函数发现 1234567891011121314151617181920__int64 __fastcall main(int a1, char **a2, char **a3)&amp;#123;  char s[264]; &#x2F;&#x2F; [rsp+0h] [rbp-110h] BYREF  unsigned __int64 v5; &#x2F;&#x2F; [rsp+108h">
<meta property="og:type" content="article">
<meta property="og:title" content="攻防世界RE">
<meta property="og:url" content="https://xiyuanhuaigu.gitee.io/2023/10/20/%E6%94%BB%E9%98%B2%E4%B8%96%E7%95%8CRE/index.html">
<meta property="og:site_name" content="惜缘怀古的博客">
<meta property="og:description" content="Reversing-x64Elf-100追踪main 函数发现 1234567891011121314151617181920__int64 __fastcall main(int a1, char **a2, char **a3)&amp;#123;  char s[264]; &#x2F;&#x2F; [rsp+0h] [rbp-110h] BYREF  unsigned __int64 v5; &#x2F;&#x2F; [rsp+108h">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/c78ed35b1e3999643d52a652257558af0a15b4c9_raw.jpg">
<meta property="article:published_time" content="2023-10-20T12:38:32.000Z">
<meta property="article:modified_time" content="2024-01-18T02:15:59.642Z">
<meta property="article:author" content="惜缘怀古">
<meta property="article:tag" content="惜缘怀古，博客">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/c78ed35b1e3999643d52a652257558af0a15b4c9_raw.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://xiyuanhuaigu.gitee.io/2023/10/20/%E6%94%BB%E9%98%B2%E4%B8%96%E7%95%8CRE/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '攻防世界RE',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-01-18 10:15:59'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/2.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">66</div></a></div><div class="data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a></div><div class="data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div></div><hr/></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/c78ed35b1e3999643d52a652257558af0a15b4c9_raw.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">惜缘怀古的博客</a></span><div id="menus"><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">攻防世界RE</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-10-20T12:38:32.000Z" title="发表于 2023-10-20 20:38:32">2023-10-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-01-18T02:15:59.642Z" title="更新于 2024-01-18 10:15:59">2024-01-18</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>15分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="攻防世界RE"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Reversing-x64Elf-100"><a href="#Reversing-x64Elf-100" class="headerlink" title="Reversing-x64Elf-100"></a>Reversing-x64Elf-100</h1><p>追踪main 函数发现</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">__int64 __fastcall main(int a1, char **a2, char **a3)</span><br><span class="line">&#123;</span><br><span class="line">  char s[264]; // [rsp+0h] [rbp-110h] BYREF</span><br><span class="line">  unsigned __int64 v5; // [rsp+108h] [rbp-8h]</span><br><span class="line"></span><br><span class="line">  v5 = __readfsqword(0x28u);</span><br><span class="line">  printf(&quot;Enter the password: &quot;);</span><br><span class="line">  if ( !fgets(s, 255, stdin) )</span><br><span class="line">    return 0LL;</span><br><span class="line">  if ( (unsigned int)sub_4006FD((__int64)s) )   // 关键函数实现对比</span><br><span class="line">  &#123;</span><br><span class="line">    puts(&quot;Incorrect password!&quot;);</span><br><span class="line">    return 1LL;</span><br><span class="line">  &#125;</span><br><span class="line">  else</span><br><span class="line">  &#123;</span><br><span class="line">    puts(&quot;Nice!&quot;);</span><br><span class="line">    return 0LL;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>追踪sub_4006FD函数可得</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">__int64 __fastcall sub_4006FD(__int64 a1)</span><br><span class="line">&#123;</span><br><span class="line">  int i; // [rsp+14h] [rbp-24h]</span><br><span class="line">  __int64 v3[4]; // [rsp+18h] [rbp-20h]</span><br><span class="line"></span><br><span class="line">  v3[0] = (__int64)&quot;Dufhbmf&quot;;</span><br><span class="line">  v3[1] = (__int64)&quot;pG`imos&quot;;</span><br><span class="line">  v3[2] = (__int64)&quot;ewUglpt&quot;;</span><br><span class="line">  for ( i = 0; i &lt;= 11; ++i )</span><br><span class="line">  &#123;</span><br><span class="line">    if ( *(char *)(v3[i % 3] + 2 * (i / 3)) - *(char *)(i + a1) != 1 )  // 具体意思就是访问数组中的特定的字符串的特定的值与输入的字符串的指定的值相减等于1</span><br><span class="line">      return 1LL;</span><br><span class="line">  &#125;</span><br><span class="line">  return 0LL;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">这段代码是在进行一个条件判断，如果条件满足，则返回 1；否则继续执行。具体来说，该语句检查 v3 是一个长度为 3 的字符指针数组（或者是一个包含三个字符数组的二维数组），其中第 i % 3 个元素是一个字符数组，长度为偶数。并且，在索引为 i / 3 的位置上的字符减去地址为 i + a1 的字符的 ASCII 码的差不等于 1。</span><br><span class="line"></span><br><span class="line">下面来逐个解释一下每个部分的含义：</span><br><span class="line"></span><br><span class="line">    v3 是一个字符指针数组（或者是一个包含三个字符数组的二维数组），其下标从 0 开始，因此 i % 3 会得到 v3 中第 i 个元素。该元素应该是一个字符数组，长度为偶数。</span><br><span class="line"></span><br><span class="line">    2 * (i / 3) 是通过整除来计算出字符数组中要访问的下标。由于每个数组长度为偶数，因此 (i / 3) 得到的结果也是偶数。所以 2 * (i / 3) 就是用来访问字符数组中特定位置的下标。</span><br><span class="line"></span><br><span class="line">    *(char *)(v3[i % 3] + 2 * (i / 3)) 表示根据上述计算得到字符数组中特定位置的值。</span><br><span class="line"></span><br><span class="line">    i + a1 表示以地址 a1 为起始位置的指针偏移 i 个字节的位置得到的值。</span><br><span class="line"></span><br><span class="line">    *(char *)(i + a1) 表示以地址 a1 为起始位置的指针偏移 i 个字节的位置得到的值。</span><br><span class="line"></span><br><span class="line">    *(char *)(v3[i % 3] + 2 * (i / 3)) - *(char *)(i + a1) 表示计算上述两个值的差，也就是字符数组中特定位置的值减去 a1 指针偏移后的值。</span><br><span class="line"></span><br><span class="line">    最后，检查这个差是否等于 1。如果不相等，返回 1；否则继续执行。注意，该函数返回一个 long long 类型的整数（1LL），表示函数执行成功或失败的状态。</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">key1=&quot;Dufhbmf&quot;</span><br><span class="line">key2=&quot;pG`imos&quot;</span><br><span class="line">key3=&quot;ewUglpt&quot;</span><br><span class="line">flag=&quot;&quot;</span><br><span class="line">key4=[key1,key2,key3]</span><br><span class="line">for i in range(12):</span><br><span class="line">	flag+=chr(ord(key4[i%3][(2*int(i/3))]) -1)</span><br><span class="line">print(flag)</span><br></pre></td></tr></table></figure>



<h1 id="666"><a href="#666" class="headerlink" title="666"></a>666</h1><p>没有加壳</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">int __cdecl main(int argc, const char **argv, const char **envp)</span><br><span class="line">&#123;</span><br><span class="line">  char s[240]; // [rsp+0h] [rbp-1E0h] BYREF</span><br><span class="line">  char v5[240]; // [rsp+F0h] [rbp-F0h] BYREF</span><br><span class="line"></span><br><span class="line">  memset(s, 0, 0x1EuLL);</span><br><span class="line">  printf(&quot;Please Input Key: &quot;);</span><br><span class="line">  __isoc99_scanf(&quot;%s&quot;, v5);</span><br><span class="line">  encode(v5, s);</span><br><span class="line">  if ( strlen(v5) == key )</span><br><span class="line">  &#123;</span><br><span class="line">    if ( !strcmp(s, enflag) )</span><br><span class="line">      puts(&quot;You are Right&quot;);</span><br><span class="line">    else</span><br><span class="line">      puts(&quot;flag&#123;This_1s_f4cker_flag&#125;&quot;);</span><br><span class="line">  &#125;</span><br><span class="line">  return 0;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">memset(s, 0, 0x1EuLL) 是一个内存操作函数，用于将内存块 s 的前 0x1E 个字节设置为0。具体来说，它的参数包括：</span><br><span class="line"></span><br><span class="line">    s：指向要操作的内存块的指针。</span><br><span class="line">    0：用于填充内存块的值，这里是0。</span><br><span class="line">    0x1EuLL：指定要设置为0的字节数。</span><br><span class="line"></span><br><span class="line">因此，执行 memset(s, 0, 0x1EuLL) 后，内存块 s 的前 0x1E 个字节都会被设置为0。这种操作常用于初始化内存块或清空敏感数据。注意，0x1EuLL 是一个长整型字面量，表示十进制的 30。</span><br></pre></td></tr></table></figure>

<p>追踪函数encode，发现关键代码</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">int __fastcall encode(const char *a1, __int64 a2)</span><br><span class="line">&#123;</span><br><span class="line">  char v3[104]; // [rsp+10h] [rbp-70h]</span><br><span class="line">  int v4; // [rsp+78h] [rbp-8h]</span><br><span class="line">  int i; // [rsp+7Ch] [rbp-4h]</span><br><span class="line"></span><br><span class="line">  i = 0;</span><br><span class="line">  v4 = 0;</span><br><span class="line">  if ( strlen(a1) != key )</span><br><span class="line">    return puts(&quot;Your Length is Wrong&quot;);</span><br><span class="line">  for ( i = 0; i &lt; key; i += 3 )</span><br><span class="line">  &#123;</span><br><span class="line">    v3[i + 64] = key ^ (a1[i] + 6);</span><br><span class="line">    v3[i + 33] = (a1[i + 1] - 6) ^ key;</span><br><span class="line">    v3[i + 2] = a1[i + 2] ^ 6 ^ key;   </span><br><span class="line">    *(_BYTE *)(a2 + i) = v3[i + 64];   // 内存复制操作</span><br><span class="line">    *(_BYTE *)(a2 + i + 1LL) = v3[i + 33];</span><br><span class="line">    *(_BYTE *)(a2 + i + 2LL) = v3[i + 2];</span><br><span class="line">  &#125;</span><br><span class="line">  return a2;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">*(_BYTE *)(a2 + i) 是一个内存访问操作，用于获取位于内存地址 (a2 + i) 的字节值。</span><br><span class="line"></span><br><span class="line">具体解释如下：</span><br><span class="line"></span><br><span class="line">    (a2 + i) 表示内存地址 a2 与偏移量 i 的和，即指向内存中的某个位置。</span><br><span class="line">    (_BYTE *) 是类型转换操作符，将得到的地址转换为指向字节的指针。</span><br><span class="line">    * 是间接引用操作符，通过指针访问该地址处的值。</span><br><span class="line"></span><br><span class="line">因此，*(_BYTE *)(a2 + i) 表示获取指针 (a2 + i) 指向的内存地址处的字节值。这种语法常用于访问和处理特定地址上的数据。</span><br><span class="line"> 	</span><br></pre></td></tr></table></figure>

<p>读取key的值为18，将enflag的ascii码转为10进制数。</p>
<p>脚本：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">str</span> = [</span><br><span class="line">  <span class="number">0x69</span>, <span class="number">0x7A</span>, <span class="number">0x77</span>, <span class="number">0x68</span>, <span class="number">0x72</span>, <span class="number">0x6F</span>, <span class="number">0x7A</span>, <span class="number">0x22</span>, <span class="number">0x22</span>, <span class="number">0x77</span>,</span><br><span class="line">  <span class="number">0x22</span>, <span class="number">0x76</span>, <span class="number">0x2E</span>, <span class="number">0x4B</span>, <span class="number">0x22</span>, <span class="number">0x2E</span>, <span class="number">0x4E</span>, <span class="number">0x69</span>, <span class="number">0x00</span></span><br><span class="line">]</span><br><span class="line">flag = <span class="string">&quot;&quot;</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">0</span> , <span class="number">18</span> ,<span class="number">3</span>):</span><br><span class="line">    flag += <span class="built_in">chr</span>((<span class="built_in">int</span>(<span class="built_in">str</span>[i]) ^ <span class="number">18</span>) - <span class="number">6</span>)</span><br><span class="line">    flag += <span class="built_in">chr</span>((<span class="built_in">int</span>(<span class="built_in">str</span>[i+<span class="number">1</span>]) ^ <span class="number">18</span>) + <span class="number">6</span>)</span><br><span class="line">    flag += <span class="built_in">chr</span>(<span class="built_in">int</span>(<span class="built_in">str</span>[i+<span class="number">2</span>]) ^ <span class="number">18</span> ^ <span class="number">6</span>)</span><br><span class="line"><span class="built_in">print</span>(flag)</span><br></pre></td></tr></table></figure>



<h1 id="easyRE1"><a href="#easyRE1" class="headerlink" title="easyRE1"></a>easyRE1</h1><p>没加壳</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">int __cdecl main(int argc, const char **argv, const char **envp)</span><br><span class="line">&#123;</span><br><span class="line">  char s1[264]; // [rsp+10h] [rbp-110h] BYREF</span><br><span class="line">  unsigned __int64 v5; // [rsp+118h] [rbp-8h]</span><br><span class="line"></span><br><span class="line">  v5 = __readfsqword(0x28u);</span><br><span class="line">  puts(&quot;What is the password?&quot;);</span><br><span class="line">  gets(s1);</span><br><span class="line">  if ( !strcmp(s1, &quot;the password&quot;) )</span><br><span class="line">    puts(&quot;FLAG:db2f62a36a018bce28e46d976e3f9864&quot;);</span><br><span class="line">  else</span><br><span class="line">    puts(&quot;Wrong!!&quot;);</span><br><span class="line">  return 0;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>一眼就看出来</p>
<h1 id="lucknum"><a href="#lucknum" class="headerlink" title="lucknum"></a>lucknum</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">int __cdecl main(int argc, const char **argv, const char **envp)</span><br><span class="line">&#123;</span><br><span class="line">  int v4; // [rsp+Ch] [rbp-34h] BYREF</span><br><span class="line">  char s[48]; // [rsp+10h] [rbp-30h] BYREF</span><br><span class="line"></span><br><span class="line">  strcpy(s, &quot;flag&#123;c0ngr@tul@ti0n_f0r_luck_numb3r&#125;&quot;);</span><br><span class="line">  v4 = 0;</span><br><span class="line">  __isoc99_scanf(&amp;unk_2004, &amp;v4);</span><br><span class="line">  if ( v4 == 7 )</span><br><span class="line">    return puts(s);</span><br><span class="line">  else</span><br><span class="line">    return puts(&quot;sorry!&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>一眼看出来</p>
<h1 id="reverse-re3"><a href="#reverse-re3" class="headerlink" title="reverse_re3"></a>reverse_re3</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line">__int64 sub_940()</span><br><span class="line">&#123;</span><br><span class="line">  int v0; // eax</span><br><span class="line">  int v2; // [rsp+8h] [rbp-218h]</span><br><span class="line">  int v3; // [rsp+Ch] [rbp-214h]</span><br><span class="line">  char v4[520]; // [rsp+10h] [rbp-210h] BYREF</span><br><span class="line">  unsigned __int64 v5; // [rsp+218h] [rbp-8h]</span><br><span class="line"></span><br><span class="line">  v5 = __readfsqword(0x28u);</span><br><span class="line">  v3 = 0;</span><br><span class="line">  memset(v4, 0, 0x200uLL);</span><br><span class="line">  _isoc99_scanf(&amp;unk_1278, v4, v4);</span><br><span class="line">  while ( 1 )</span><br><span class="line">  &#123;</span><br><span class="line">    do</span><br><span class="line">    &#123;</span><br><span class="line">      v2 = 0;</span><br><span class="line">      sub_86C();</span><br><span class="line">      v0 = v4[v3];</span><br><span class="line">      if ( v0 == 100 )</span><br><span class="line">      &#123;</span><br><span class="line">        v2 = sub_E23();</span><br><span class="line">      &#125;</span><br><span class="line">      else if ( v0 &gt; 100 )</span><br><span class="line">      &#123;</span><br><span class="line">        if ( v0 == 115 )</span><br><span class="line">        &#123;</span><br><span class="line">          v2 = sub_C5A();</span><br><span class="line">        &#125;</span><br><span class="line">        else if ( v0 == 119 )</span><br><span class="line">        &#123;</span><br><span class="line">          v2 = sub_A92();</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;</span><br><span class="line">      else</span><br><span class="line">      &#123;</span><br><span class="line">        if ( v0 == 27 )</span><br><span class="line">          return 0xFFFFFFFFLL;</span><br><span class="line">        if ( v0 == 97 )</span><br><span class="line">          v2 = sub_FEC();</span><br><span class="line">      &#125;</span><br><span class="line">      ++v3;</span><br><span class="line">    &#125;</span><br><span class="line">    while ( v2 != 1 );</span><br><span class="line">    if ( dword_202AB0 == 2 )</span><br><span class="line">      break;</span><br><span class="line">    ++dword_202AB0;</span><br><span class="line">  &#125;</span><br><span class="line">  puts(&quot;success! the flag is flag&#123;md5(your input)&#125;&quot;);</span><br><span class="line">  return 1LL;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>追踪 sub_86C();函数，发现数组</p>
<p><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/20231024184402.png"></p>
<p>将数据导出</p>
<p><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/20231024190349.png"></p>
<p>删去前后的数组名和括号</p>
<p>使用脚本处理为3个15*15的矩阵</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"># 打开文本文件</span><br><span class="line">with open(&#x27;data.txt&#x27;, &#x27;r&#x27;) as file:</span><br><span class="line">    # 读取文件内容</span><br><span class="line">    content = file.read()</span><br><span class="line"></span><br><span class="line"># 将字符串分割为数字列表</span><br><span class="line">data = list(map(int, content.replace(&#x27;,&#x27;, &#x27;&#x27;).split()))</span><br><span class="line"></span><br><span class="line"># 转换为矩阵</span><br><span class="line">matrix = []</span><br><span class="line">row = []</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">for i in range(len(data)):</span><br><span class="line">    row.append(data[i])</span><br><span class="line">    if (i + 1) % 15 == 0:</span><br><span class="line">        matrix.append(row)</span><br><span class="line">        row = []</span><br><span class="line"></span><br><span class="line"># 输出矩阵</span><br><span class="line">for i, row in enumerate(matrix):</span><br><span class="line">    print(row)</span><br><span class="line">    if (i + 1) % 15 == 0:</span><br><span class="line">        print()</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</span><br><span class="line">[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</span><br><span class="line">[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</span><br><span class="line">[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</span><br><span class="line">[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</span><br><span class="line"></span><br><span class="line">[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 0, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0]</span><br><span class="line">[1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]</span><br><span class="line">[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0]</span><br><span class="line">[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</span><br><span class="line">[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</span><br><span class="line"></span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]</span><br><span class="line">[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0]</span><br></pre></td></tr></table></figure>

<p>“3”是起点，“4”是终点，“1”是可走的，“0”是不可走的</p>
<p> 最后将三个迷宫的解法，并在一起</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ddsssddddsssdssdddddsssddddsssaassssdddsddssddwddssssssdddssssdddss</span><br></pre></td></tr></table></figure>

<p>md5加密一下得到flag</p>
<h1 id="1000Click"><a href="#1000Click" class="headerlink" title="1000Click"></a>1000Click</h1><p>shift + F12搜索得到很多flag,发现只有一个调用的，该flag即为正确的flag</p>
<p><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/20231024193956.png"></p>
<h1 id="crypt"><a href="#crypt" class="headerlink" title="crypt"></a>crypt</h1><p>下载附件得到crypt.exe，拖入exeinfope分析得64bit,无壳。拖入ida64，打开搜索main函数，f5反编译，发现了对字符串Str的复制。看到下方和Str有关联的是v9，点击<strong>sub_140001120</strong>，以及<strong>sub_140001240</strong>(v9, (__int64)v10, v4);可以得到两段函数。</p>
<p><a target="_blank" rel="noopener" href="https://eneldo.fun/wp-content/uploads/2022/11/image-1.png"><img src="https://eneldo.fun/wp-content/uploads/2022/11/image-1-300x171.png" alt="img"></a> 【初始化S和T，以及初始化排列S】</p>
<p><a target="_blank" rel="noopener" href="https://eneldo.fun/wp-content/uploads/2022/11/image.png"><img src="https://eneldo.fun/wp-content/uploads/2022/11/image-300x229.png" alt="img"></a> 【初始化密钥流】</p>
<p>那么经过分析，密钥就是Str字符串。看完两段函数后，返回main函数，最终找到if ( ((unsigned <strong>int8)v10[i] ^ 34) != (unsigned</strong> int8)byte_14013B000[i] )，这里对byte_14013B000[i] 进行了异或处理。自此我们可以判断加密方式是<strong>RC4加密</strong></p>
<p>*<strong>对明文使用同一个密钥异或两次最后是得到原文的。</strong></p>
<p>因此只需要对byte_14013B000[i]进行rc4解密就可以了。解密脚本如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">unsigned char ida_chars[] =</span><br><span class="line">&#123;</span><br><span class="line">  0x9E, 0xE7, 0x30, 0x5F, 0xA7, 0x01, 0xA6, 0x53, 0x59, 0x1B, </span><br><span class="line">  0x0A, 0x20, 0xF1, 0x73, 0xD1, 0x0E, 0xAB, 0x09, 0x84, 0x0E, </span><br><span class="line">  0x8D, 0x2B, 0x00, 0x00</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>解密运算：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">from Cryptodome.Cipher import ARC4</span><br><span class="line"></span><br><span class="line">encrypted_data = bytes([0x9E, 0xE7, 0x30, 0x5F, 0xA7, 0x01, 0xA6, 0x53, 0x59, 0x1B, 0x0A, 0x20, 0xF1, 0x73, 0xD1, 0x0E, 0xAB, 0x09, 0x84, 0x0E, 0x8D, 0x2B])</span><br><span class="line">key = b&quot;12345678abcdefghijklmnopqrspxyz&quot;  # 替换为你的密钥</span><br><span class="line"></span><br><span class="line">cipher = ARC4.new(key)</span><br><span class="line">decrypted_data = cipher.decrypt(encrypted_data)</span><br><span class="line"></span><br><span class="line"># 转换为可变字节数组</span><br><span class="line">decrypted_data = bytearray(decrypted_data)</span><br><span class="line"></span><br><span class="line"># 对每个字节进行位异或运算</span><br><span class="line">for i in range(len(decrypted_data)):</span><br><span class="line">    decrypted_data[i] ^= 34</span><br><span class="line"></span><br><span class="line">plaintext = decrypted_data.decode()</span><br><span class="line"></span><br><span class="line">print(plaintext)</span><br></pre></td></tr></table></figure>

<h1 id="happyctf"><a href="#happyctf" class="headerlink" title="happyctf"></a>happyctf</h1><p>无壳拖入IDA</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br></pre></td><td class="code"><pre><span class="line">int __cdecl main(int argc, const char **argv, const char **envp)</span><br><span class="line">&#123;</span><br><span class="line">  int v4; // [esp+5Ch] [ebp-70h]</span><br><span class="line">  char *v5; // [esp+60h] [ebp-6Ch]</span><br><span class="line">  char v6[27]; // [esp+6Ch] [ebp-60h] BYREF</span><br><span class="line">  char v7; // [esp+87h] [ebp-45h]</span><br><span class="line">  char *v8; // [esp+88h] [ebp-44h]</span><br><span class="line">  char *v9; // [esp+8Ch] [ebp-40h]</span><br><span class="line">  char *v10; // [esp+90h] [ebp-3Ch]</span><br><span class="line">  char v11[12]; // [esp+98h] [ebp-34h] BYREF</span><br><span class="line">  char v12[24]; // [esp+A4h] [ebp-28h] BYREF</span><br><span class="line">  int v13; // [esp+C8h] [ebp-4h]</span><br><span class="line"></span><br><span class="line">  sub_402930();</span><br><span class="line">  v13 = 0;</span><br><span class="line">  sub_401530((int)&amp;unk_4DDAF8, &quot;please input flag&quot;);</span><br><span class="line">  sub_4039B0(sub_402310);</span><br><span class="line">  sub_401500(&amp;dword_4DDA80, v12);</span><br><span class="line">  if ( sub_405DE0(v12) == 24 )</span><br><span class="line">  &#123;</span><br><span class="line">    sub_402A20(v11);</span><br><span class="line">    LOBYTE(v13) = 1;</span><br><span class="line">    sub_402570(v11);</span><br><span class="line">    v10 = v12;</span><br><span class="line">    v9 = (char *)sub_405270(v12);</span><br><span class="line">    v8 = (char *)sub_4052B0(v12);</span><br><span class="line">    while ( v9 != v8 )</span><br><span class="line">    &#123;</span><br><span class="line">      v7 = *v9;</span><br><span class="line">      sub_403B70(v7);   // 关键函数</span><br><span class="line">      ++v9;</span><br><span class="line">    &#125;</span><br><span class="line">    qmemcpy(v6, &quot;rxusoCqxw&#123;yqK`&#123;KZqag&#123;r`i&quot;, 24);</span><br><span class="line">    sub_402590(v6);</span><br><span class="line">    v5 = (char *)sub_405290(v11);</span><br><span class="line">    v4 = sub_4052E0(v11);</span><br><span class="line">    while ( v5 != (char *)v4 )</span><br><span class="line">    &#123;</span><br><span class="line">      if ( !(unsigned __int8)sub_403BB0(*v5) )</span><br><span class="line">      &#123;</span><br><span class="line">        sub_401530((int)&amp;unk_4DDAF8, &quot;error&quot;);</span><br><span class="line">        sub_4039B0(sub_402310);</span><br><span class="line">        LOBYTE(v13) = 0;</span><br><span class="line">        sub_4034E0(v11);</span><br><span class="line">        v13 = -1;</span><br><span class="line">        sub_403450(v12);</span><br><span class="line">        return 0;</span><br><span class="line">      &#125;</span><br><span class="line">      ++v5;</span><br><span class="line">    &#125;</span><br><span class="line">    sub_401530((int)&amp;unk_4DDAF8, &quot;good job&quot;);</span><br><span class="line">    sub_4039B0(sub_402310);</span><br><span class="line">    LOBYTE(v13) = 0;</span><br><span class="line">    sub_4034E0(v11);</span><br><span class="line">    v13 = -1;</span><br><span class="line">    sub_403450(v12);</span><br><span class="line">    return 0;</span><br><span class="line">  &#125;</span><br><span class="line">  else</span><br><span class="line">  &#123;</span><br><span class="line">    sub_401530((int)&amp;unk_4DDAF8, &quot;not enought&quot;);</span><br><span class="line">    sub_4039B0(sub_402310);</span><br><span class="line">    v13 = -1;</span><br><span class="line">    sub_403450(v12);</span><br><span class="line">    return 0;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">int __thiscall sub_403B70(void *this, char a2)</span><br><span class="line">&#123;</span><br><span class="line">  char v3[65]; // [esp+Fh] [ebp-45h] BYREF</span><br><span class="line">  void *v4; // [esp+50h] [ebp-4h]</span><br><span class="line"></span><br><span class="line">  v4 = this;</span><br><span class="line">  v3[0] = a2 ^ 0x14;   //关键代码与或运算</span><br><span class="line">  sub_406170(v3);</span><br><span class="line">  return ++dword_4DD8F8;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p>此代码主要实现了对输入的字符的每一个字母进行与或运算，最终与</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rxusoCqxw&#123;yqK`&#123;KZqag&#123;r`i</span><br></pre></td></tr></table></figure>

<p>进行对比，所以直接对字符串每个字母进行与或即可。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">str = &quot;rxusoCqxw&#123;yqK`&#123;KZqag&#123;r`i&quot;</span><br><span class="line">flag = &#x27;&#x27;</span><br><span class="line">for i in range(len(str)):</span><br><span class="line">    flag += chr(ord(str[i]) ^ 0x14)</span><br><span class="line">print(flag)</span><br></pre></td></tr></table></figure>



<h1 id="xxxorrr"><a href="#xxxorrr" class="headerlink" title="xxxorrr"></a>xxxorrr</h1></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">惜缘怀古</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://xiyuanhuaigu.gitee.io/2023/10/20/%E6%94%BB%E9%98%B2%E4%B8%96%E7%95%8CRE/">https://xiyuanhuaigu.gitee.io/2023/10/20/%E6%94%BB%E9%98%B2%E4%B8%96%E7%95%8CRE/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://xiyuanhuaigu.gitee.io" target="_blank">惜缘怀古的博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/c78ed35b1e3999643d52a652257558af0a15b4c9_raw.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/11/06/2023%E8%93%9D%E5%B8%BD%E6%9D%AF%E5%86%B3%E8%B5%9BWP/"><img class="prev-cover" src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/20231106163334.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">2023蓝帽杯决赛WP</div></div></a></div><div class="next-post pull-right"><a href="/2023/09/22/%E5%AE%89%E5%8D%93%E5%B8%B8%E7%94%A8%E7%9B%AE%E5%BD%95/"><img class="next-cover" src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/mmexport1694863328916.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">安卓常用目录</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/2.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">惜缘怀古</div><div class="author-info__description">唯有那份炫目，未曾忘却</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">66</div></a></div><div class="card-info-data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a></div><div class="card-info-data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Reversing-x64Elf-100"><span class="toc-number">1.</span> <span class="toc-text">Reversing-x64Elf-100</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#666"><span class="toc-number">2.</span> <span class="toc-text">666</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#easyRE1"><span class="toc-number">3.</span> <span class="toc-text">easyRE1</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#lucknum"><span class="toc-number">4.</span> <span class="toc-text">lucknum</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#reverse-re3"><span class="toc-number">5.</span> <span class="toc-text">reverse_re3</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#1000Click"><span class="toc-number">6.</span> <span class="toc-text">1000Click</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#crypt"><span class="toc-number">7.</span> <span class="toc-text">crypt</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#happyctf"><span class="toc-number">8.</span> <span class="toc-text">happyctf</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#xxxorrr"><span class="toc-number">9.</span> <span class="toc-text">xxxorrr</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/11/06/2023%E8%93%9D%E5%B8%BD%E6%9D%AF%E5%86%B3%E8%B5%9BWP/" title="2023蓝帽杯决赛WP"><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/20231106163334.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="2023蓝帽杯决赛WP"/></a><div class="content"><a class="title" href="/2023/11/06/2023%E8%93%9D%E5%B8%BD%E6%9D%AF%E5%86%B3%E8%B5%9BWP/" title="2023蓝帽杯决赛WP">2023蓝帽杯决赛WP</a><time datetime="2023-11-06T08:31:51.000Z" title="发表于 2023-11-06 16:31:51">2023-11-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/10/20/%E6%94%BB%E9%98%B2%E4%B8%96%E7%95%8CRE/" title="攻防世界RE"><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/c78ed35b1e3999643d52a652257558af0a15b4c9_raw.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="攻防世界RE"/></a><div class="content"><a class="title" href="/2023/10/20/%E6%94%BB%E9%98%B2%E4%B8%96%E7%95%8CRE/" title="攻防世界RE">攻防世界RE</a><time datetime="2023-10-20T12:38:32.000Z" title="发表于 2023-10-20 20:38:32">2023-10-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/09/22/%E5%AE%89%E5%8D%93%E5%B8%B8%E7%94%A8%E7%9B%AE%E5%BD%95/" title="安卓常用目录"><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/mmexport1694863328916.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="安卓常用目录"/></a><div class="content"><a class="title" href="/2023/09/22/%E5%AE%89%E5%8D%93%E5%B8%B8%E7%94%A8%E7%9B%AE%E5%BD%95/" title="安卓常用目录">安卓常用目录</a><time datetime="2023-09-22T01:27:02.000Z" title="发表于 2023-09-22 09:27:02">2023-09-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/09/22/010Editor%E7%A0%B4%E8%A7%A3/" title="010Editor破解"><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/1694867487605.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="010Editor破解"/></a><div class="content"><a class="title" href="/2023/09/22/010Editor%E7%A0%B4%E8%A7%A3/" title="010Editor破解">010Editor破解</a><time datetime="2023-09-22T00:33:10.000Z" title="发表于 2023-09-22 08:33:10">2023-09-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/08/24/%E6%9F%90APP%E7%9A%84%E9%80%86%E5%90%91%E5%88%86%E6%9E%90/" title="某APP的逆向分析"><img src="https://xyhutc.oss-cn-qingdao.aliyuncs.com/giteetuchuang/a4c8982faff8839d06cc010c864e02e8092efb23_raw.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="某APP的逆向分析"/></a><div class="content"><a class="title" href="/2023/08/24/%E6%9F%90APP%E7%9A%84%E9%80%86%E5%90%91%E5%88%86%E6%9E%90/" title="某APP的逆向分析">某APP的逆向分析</a><time datetime="2023-08-24T14:02:11.000Z" title="发表于 2023-08-24 22:02:11">2023-08-24</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By 惜缘怀古</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>